import { getTmRuleDetectionByPid } from '@/api/fmea/common/project'

export default {
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    // v-model/value 1-10
    value: {
      type: Number,
      default: undefined
    },
    // 项目ID
    projectId: {
      type: Number,
      required: true
    },
    // APP ID PFMEA/MFMEA/DFMEA
    appId: {
      type: String,
      required: true
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      selectValue: this.value,
      visible: false,
      tableData: []
    }
  },
  watch: {
    value(val, oldVal) {
      if (val !== oldVal) {
        this.selectValue = val
      }
    }
  },
  methods: {
    toSelect(value) {
      this.selectValue = value
      this.$emit('change', value)
      this.onClose()
    },
    dblclick(row) {
      this.toSelect(row.scoreNumber)
    },
    onClose() {
      this.visible = false
    },
    clear() {
      this.selectValue = undefined
      this.$emit('change', this.selectValue)
    },
    focus() {
      this.$refs.scoreInput.blur()
      this.visible = true
    }
  }
}
